package com.codedancer.campus.client.api.feedbackRecord;

import cn.hutool.core.bean.BeanUtil;
import com.codedancer.campus.client.api.feedbackRecord.ro.FeedbackRecordAddRo;
import com.codedancer.campus.client.service.IFeedbackRecordService;
import com.codedancer.campus.client.service.bo.feedbackRecord.FeedbackRecordAddBo;
import com.codedancer.campus.common.core.BaseApi;
import com.codedancer.campus.common.response.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/feedback-record")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE,
    RequestMethod.PUT}, maxAge = 3600)
@Api(value = "反馈记录Api", description = "反馈记录Api", tags = "反馈记录Api")
public class FeedbackRecordApi extends BaseApi {

    @Autowired
    private IFeedbackRecordService feedbackRecordService;

    @PostMapping("/add")
    @ApiOperation("新增反馈记录")
    public ApiResponse<Void> add(@RequestBody @Valid @ApiParam(value = "反馈记录添加Ro", required = true)
        FeedbackRecordAddRo feedbackRecordAddRo) {
        FeedbackRecordAddBo feedbackRecordAddBo = BeanUtil.copyProperties(feedbackRecordAddRo,
            FeedbackRecordAddBo.class);
        feedbackRecordAddBo.setCurrentUserUuid(currentLoginUuid());
        feedbackRecordService.add(feedbackRecordAddBo);
        return success();
    }
}
